﻿using System;
using System.Collections.Generic;
using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;
using Abp.Authorization.Roles;
using Microsoft.AspNetCore.Identity;

namespace Abp.Authorization.Users;

public interface IAbpUserStore<TRole, TUser>
    where TRole : AbpRole<TUser>
    where TUser : AbpUser<TUser>
{
    Task RemoveLoginAsync(TUser user, string loginProvider, string providerKey, CancellationToken cancellationToken);
    void RemoveLogin(TUser user, string loginProvider, string providerKey, CancellationToken cancellationToken);
    Task<IList<UserLoginInfo>> GetLoginsAsync(TUser user, CancellationToken cancellationToken);
    IList<UserLoginInfo> GetLogins(TUser user, CancellationToken cancellationToken);
    Task<TUser> FindByLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken);
    TUser FindByLogin(string loginProvider, string providerKey, CancellationToken cancellationToken);
    Task<bool> GetEmailConfirmedAsync(TUser user, CancellationToken cancellationToken);
    bool GetEmailConfirmed(TUser user, CancellationToken cancellationToken);
    Task SetEmailConfirmedAsync(TUser user, bool confirmed, CancellationToken cancellationToken);
    void SetEmailConfirmed(TUser user, bool confirmed, CancellationToken cancellationToken);
    Task SetEmailAsync(TUser user, string email, CancellationToken cancellationToken);
    void SetEmail(TUser user, string email, CancellationToken cancellationToken);
    Task<string> GetEmailAsync(TUser user, CancellationToken cancellationToken);
    string GetEmail(TUser user, CancellationToken cancellationToken);
    Task<string> GetNormalizedEmailAsync(TUser user, CancellationToken cancellationToken);
    string GetNormalizedEmail(TUser user, CancellationToken cancellationToken);
    Task SetNormalizedEmailAsync(TUser user, string normalizedEmail, CancellationToken cancellationToken);
    void SetNormalizedEmail(TUser user, string normalizedEmail, CancellationToken cancellationToken);
    Task<TUser> FindByEmailAsync(string normalizedEmail, CancellationToken cancellationToken);
    TUser FindByEmail(string normalizedEmail, CancellationToken cancellationToken);
    Task<DateTimeOffset?> GetLockoutEndDateAsync(TUser user, CancellationToken cancellationToken);
    DateTimeOffset? GetLockoutEndDate(TUser user, CancellationToken cancellationToken);
    Task SetLockoutEndDateAsync(TUser user, DateTimeOffset? lockoutEnd, CancellationToken cancellationToken);
    void SetLockoutEndDate(TUser user, DateTimeOffset? lockoutEnd, CancellationToken cancellationToken);
    Task<int> IncrementAccessFailedCountAsync(TUser user, CancellationToken cancellationToken);
    int IncrementAccessFailedCount(TUser user, CancellationToken cancellationToken);
    Task ResetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken);
    void ResetAccessFailedCount(TUser user, CancellationToken cancellationToken);
    Task<int> GetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken);
    int GetAccessFailedCount(TUser user, CancellationToken cancellationToken);
    Task<bool> GetLockoutEnabledAsync(TUser user, CancellationToken cancellationToken);
    bool GetLockoutEnabled(TUser user, CancellationToken cancellationToken);
    Task SetLockoutEnabledAsync(TUser user, bool enabled, CancellationToken cancellationToken);
    void SetLockoutEnabled(TUser user, bool enabled, CancellationToken cancellationToken);
    Task SetPhoneNumberAsync(TUser user, string phoneNumber, CancellationToken cancellationToken);
    void SetPhoneNumber(TUser user, string phoneNumber, CancellationToken cancellationToken);
    Task<string> GetPhoneNumberAsync(TUser user, CancellationToken cancellationToken);
    string GetPhoneNumber(TUser user, CancellationToken cancellationToken);
    Task<bool> GetPhoneNumberConfirmedAsync(TUser user, CancellationToken cancellationToken);
    bool GetPhoneNumberConfirmed(TUser user, CancellationToken cancellationToken);
    Task SetPhoneNumberConfirmedAsync(TUser user, bool confirmed, CancellationToken cancellationToken);
    void SetPhoneNumberConfirmed(TUser user, bool confirmed, CancellationToken cancellationToken);
    Task SetSecurityStampAsync(TUser user, string stamp, CancellationToken cancellationToken);
    void SetSecurityStamp(TUser user, string stamp, CancellationToken cancellationToken);
    Task<string> GetSecurityStampAsync(TUser user, CancellationToken cancellationToken);
    string GetSecurityStamp(TUser user, CancellationToken cancellationToken);
    Task SetTwoFactorEnabledAsync(TUser user, bool enabled, CancellationToken cancellationToken);
    void SetTwoFactorEnabled(TUser user, bool enabled, CancellationToken cancellationToken);
    Task<bool> GetTwoFactorEnabledAsync(TUser user, CancellationToken cancellationToken);
    bool GetTwoFactorEnabled(TUser user, CancellationToken cancellationToken);
    Task<IList<TUser>> GetUsersForClaimAsync(Claim claim, CancellationToken cancellationToken);
    IList<TUser> GetUsersForClaim(Claim claim, CancellationToken cancellationToken);
    Task<IList<TUser>> GetUsersInRoleAsync(string normalizedRoleName, CancellationToken cancellationToken);
    IList<TUser> GetUsersInRole(string normalizedRoleName, CancellationToken cancellationToken);
    Task SetTokenAsync(TUser user, string loginProvider, string name, string value, CancellationToken cancellationToken);
    void SetToken(TUser user, string loginProvider, string name, string value, CancellationToken cancellationToken);
    Task RemoveTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken);
    void RemoveToken(TUser user, string loginProvider, string name, CancellationToken cancellationToken);
    Task<string> GetTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken);
    string GetToken(TUser user, string loginProvider, string name, CancellationToken cancellationToken);
    Task<TUser> FindByNameOrEmailAsync(string userNameOrEmailAddress);
    TUser FindByNameOrEmail(string userNameOrEmailAddress);
    Task<TUser> FindByNameOrEmailAsync(int? tenantId, string userNameOrEmailAddress);
    TUser FindByNameOrEmail(int? tenantId, string userNameOrEmailAddress);
    Task<TUser> FindAsync(UserLoginInfo login);
    TUser Find(UserLoginInfo login);
    Task<List<TUser>> FindAllAsync(UserLoginInfo login);
    List<TUser> FindAll(UserLoginInfo login);
    Task<TUser> FindAsync(int? tenantId, UserLoginInfo login);
    TUser Find(int? tenantId, UserLoginInfo login);
    Task<string> GetUserNameFromDatabaseAsync(long userId);
    string GetUserNameFromDatabase(long userId);
    Task AddPermissionAsync(TUser user, PermissionGrantInfo permissionGrant);
    void AddPermission(TUser user, PermissionGrantInfo permissionGrant);
    Task RemovePermissionAsync(TUser user, PermissionGrantInfo permissionGrant);
    void RemovePermission(TUser user, PermissionGrantInfo permissionGrant);
    Task<IList<PermissionGrantInfo>> GetPermissionsAsync(long userId);
    IList<PermissionGrantInfo> GetPermissions(long userId);
    Task<bool> HasPermissionAsync(long userId, PermissionGrantInfo permissionGrant);
    bool HasPermission(long userId, PermissionGrantInfo permissionGrant);
    Task RemoveAllPermissionSettingsAsync(TUser user);
    void RemoveAllPermissionSettings(TUser user);
    Task SetAuthenticatorKeyAsync(TUser user, string key, CancellationToken cancellationToken);
    void SetAuthenticatorKey(TUser user, string key, CancellationToken cancellationToken);
    Task<string> GetAuthenticatorKeyAsync(TUser user, CancellationToken cancellationToken);
    string GetAuthenticatorKey(TUser user, CancellationToken cancellationToken);
    Task AddTokenValidityKeyAsync(TUser user, string tokenValidityKey, DateTime expireDate, CancellationToken cancellationToken);
    void AddTokenValidityKey(TUser user, string tokenValidityKey, DateTime expireDate, CancellationToken cancellationToken);
    Task<bool> IsTokenValidityKeyValidAsync(TUser user, string tokenValidityKey, CancellationToken cancellationToken);
    bool IsTokenValidityKeyValid(TUser user, string tokenValidityKey, CancellationToken cancellationToken);
    Task RemoveTokenValidityKeyAsync(TUser user, string tokenValidityKey, CancellationToken cancellationToken);
    void RemoveTokenValidityKey(TUser user, string tokenValidityKey, CancellationToken cancellationToken);
}